package org.vidyakiran.app.server;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.vidyakiran.app.client.GreetingService;
import org.vidyakiran.app.server.dao.impl.OrganisationDetailDaoJpaImpl;
import org.vidyakiran.app.server.domain.entity.Organisation;

/**
 * The server side implementation of the RPC service.
 */
@Service
public class GreetingServiceImpl //extends RemoteServiceServlet 
	implements GreetingService {

	private static final long serialVersionUID = -566699962964185784L;

	@Autowired
	private OrganisationDetailDaoJpaImpl orgDao;
	
	public String greetServer(String input) {
//		String serverInfo = getServletContext().getServerInfo();
//		String userAgent = getThreadLocalRequest().getHeader("User-Agent");
				
		Organisation org = new Organisation();
		org.setName(input);
		org = orgDao.saveOrUpdateOrgDetails(org);
		
		
		return "Hello, " + org.getName() + " !<br>" + "user id is - " + org.getId() ; 
//				"<br>I am running " + serverInfo
//				+ ".<br><br>It looks like you are using:<br>" + userAgent;
	}
}
